﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Audio;
using System.Collections;

namespace Platformer
{
    abstract class NPC
    {
        protected Vector2 pos;
        protected Animation sprite;
        protected AnimationPlayer player;
        protected ArrayList sayings;
        protected int sayingsPos = 0;
        public Rectangle boundingBox
        {
            get
            {

                int width = (int)(sprite.FrameWidth * 0.35);
                int left = (sprite.FrameWidth - width) / 2;
                int height = (int)(sprite.FrameWidth * 0.7);
                int top = sprite.FrameHeight - height;
                Rectangle localBounds = new Rectangle(left, top, width, height);
                int leftR = (int)Math.Round(pos.X - player.Origin.X) + localBounds.X;
                int topR = (int)Math.Round(pos.Y - player.Origin.Y) + localBounds.Y;

                return new Rectangle(leftR, topR, localBounds.Width, localBounds.Height);
            }
        }


        public NPC(Vector2 pos, Level l, string assetPath)
        {
            this.pos = pos;
            sprite = new Animation(l.Content.Load<Texture2D>(assetPath), 100, true);
            player = new AnimationPlayer();
            sayings = new ArrayList();
            player.PlayAnimation(sprite);
        }

        //A constructor to please the compiler gods
        public NPC()
        {
        }


        public abstract string getWhatToSay();

        public void Update(GameTime gt)
        {

        }

        public void Draw(SpriteBatch batch, GameTime gt)
        {
            player.Draw(gt, batch, pos, SpriteEffects.None);
        }

        public string Name { get; set; }
    }
}
